package cn.iocoder.yudao.adminserver.modules.system.controller.common;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.adminserver.modules.system.controller.common.vo.SysCaptchaImageRespVO;
import cn.iocoder.yudao.adminserver.modules.system.service.common.SysCaptchaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Api(tags = "验证码")
@RestController
@RequestMapping("/system/captcha")
public class SysCaptchaController {

    @Resource
    private SysCaptchaService captchaService;

    /**
     * @api {GET} /system/captcha/get-image getCaptchaImage
     * @apiVersion 1.0.0
     * @apiGroup SysCaptchaController
     * @apiName getCaptchaImage
     * @apiSuccess (响应结果) {Number} code 错误码
     * @apiSuccess (响应结果) {Object} data 返回数据
     * @apiSuccess (响应结果) {String} data.uuid
     * @apiSuccess (响应结果) {String} data.img
     * @apiSuccess (响应结果) {String} msg 错误提示，用户可阅读
     * @apiSuccessExample 响应结果示例
     * {"msg":"XED","code":5997,"data":{"img":"dcNlJG","uuid":"SMPYJ"}}
     */
    @GetMapping("/get-image")
    @ApiOperation("生成图片验证码")
    public CommonResult<SysCaptchaImageRespVO> getCaptchaImage() {
        return success(captchaService.getCaptchaImage());
    }

}
